﻿$(function(){	
    $('.pager_Home').live('click', function(){
        var rawModuleId = $('.pager_Home').parent().parent().attr('id');
        // remove leading 'Module_' string
        var ModuleId = rawModuleId.substr(7);          
        $('.CurrentPageState').val(0);
        var root = $('#WebRoots_GetWebRoot').val();
        $.post(root + 'Modules/viNews/News/InplaceRendering.aspx?ModuleId=' + ModuleId + '&Page=' + 0, function (data) {
            $('.pager_Home').parent().parent().replaceWith(data);
        });
    });
    
    $('.pager_Prev').live('click', function(){
        var rawModuleId = $('.pager_Prev').parent().parent().attr('id');
        // remove leading 'Module_' string
        var ModuleId = rawModuleId.substr(7);   
        var Page = $('.CurrentPageState').val();        
        var CurrentPage = --Page;
        $('.CurrentPageState').val(CurrentPage);
        var root = $('#WebRoots_GetWebRoot').val();
        $.post(root + 'Modules/viNews/News/InplaceRendering.aspx?ModuleId=' + ModuleId + '&Page=' + CurrentPage, function (data) {
            $('.pager_Prev').parent().parent().replaceWith(data);
        });
    });
    
    $('.pager_Next').live('click', function(){
        var rawModuleId = $('.pager_Next').parent().parent().attr('id');
        // remove leading 'Module_' string
        var ModuleId = rawModuleId.substr(7);   
        var Page = $('.CurrentPageState').val();        
        var CurrentPage = ++Page;        
        $('.CurrentPageState').val(CurrentPage);    
        var root = $('#WebRoots_GetWebRoot').val();
        $.post(root + 'Modules/viNews/News/InplaceRendering.aspx?ModuleId=' + ModuleId + '&Page=' + CurrentPage, function (data) {
            $('.pager_Next').parent().parent().replaceWith(data);
        });
    });
});

    
